/*
 * Copyright (c) 2018, dreamkaylee@foxmail.com All Rights Reserved.
 */

package com.vip.base.common;

import lombok.Getter;

/**
 * 封装异常
 * @author vip
 * @date 2020年4月2日
 */
public class MyException extends RuntimeException {

    private static final long serialVersionUID = 3702096961571375727L;

    @Getter
    private Integer code;

    private String message;

    public MyException(String message) {
        this.code = 1;
        this.message = message;
    }

    public MyException(ExceptionEnum exceptionEnum){
        this.code = exceptionEnum.getCode();
        this.message = exceptionEnum.getMessage();
    }

    public MyException code(Integer code){
        this.code = code;
        return this;
    }

    @Override
    public String getMessage() {
        return message;
    }

}
